package cn.edu.swu.syz.io;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ImageManager imageManager = new ImageManager();
        Scanner scanner = new Scanner(System.in);
        boolean exit = false;

        while (!exit) {
            System.out.println("\n====== 图片下载系统 ======");
            System.out.println("1. 下载图片");
            System.out.println("2. 查看所有图片");
            System.out.println("3. 搜索图片");
            System.out.println("4. 退出");
            System.out.print("请输入选项：");

            int choice = scanner.nextInt();
            scanner.nextLine(); // 消耗换行符

            switch (choice) {
                case 1:
                    System.out.print("请输入图片 URL：");
                    String url = scanner.nextLine();
                    imageManager.downloadImage(url);
                    break;
                case 2:
                    imageManager.listImages();
                    break;
                case 3:
                    System.out.print("请输入图片名称：");
                    String name = scanner.nextLine();
                    imageManager.searchImage(name);
                    break;
                case 4:
                    exit = true;
                    System.out.println("程序已退出");
                    break;
                default:
                    System.out.println("无效选项，请重新输入");
            }
        }
        scanner.close();
    }
}
